package net.lee.shiro.demo.service.impl;


import net.lee.shiro.demo.dao.UserDao;
import net.lee.shiro.demo.entity.usersystem.SystemUserEntity;
import net.lee.shiro.demo.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.ExampleMatcher;
import org.springframework.stereotype.Service;
import java.util.List;
/**
 * Create by lishijun on 2018/4/11
 * Company: lianzhong
 * Domain:  ourgame.com
 * Department:Web Developer
 */

@Service
public class UserServiceImpl implements IUserService {

    @Autowired
    UserDao userDao;


    public SystemUserEntity getUserByPK(int userId)
    {
        return userDao.getOne(userId);
    }

    public List<SystemUserEntity> getUserByAccount(String accountName)
    {
        SystemUserEntity userEntity = new SystemUserEntity();
        userEntity.setEmail(accountName);
        ExampleMatcher matcher = ExampleMatcher.matching().withMatcher("email",ExampleMatcher.GenericPropertyMatchers.ignoreCase())
                .withIgnorePaths("userId");
        Example<SystemUserEntity> example = Example.of(userEntity,matcher);
        List<SystemUserEntity> result =  userDao.findAll(example);
        return  result;
    }
}
